//
//  GRXXTableViewController.m
//  uplife
//
//  Created by ZhangCheng on 2018/12/27.
//  Copyright © 2018年 ZhangCheng. All rights reserved.
//

#import "GRXXTableViewController.h"

@interface GRXXTableViewController ()
@property(nonatomic,weak)IBOutlet UILabel *usernameLabel;
@property(nonatomic,weak)IBOutlet UIImageView *sexImageView;
@end

@implementation GRXXTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.usernameLabel.text = [ZCTool sharedInstance].userInfo[@"name"];
    NSLog(@"%@",[ZCTool sharedInstance].userInfo);
    self.sexImageView.image = [UIImage imageNamed:(((NSNumber*)[ZCTool sharedInstance].userInfo[@"sex"]).integerValue==1?@"默认头像-男":@"默认头像-女")];
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row==0) {
        [self.fourthViewController performSegueWithIdentifier:@"toXGMM" sender:nil];
    }else if (indexPath.row==1){
        [self.fourthViewController performSegueWithIdentifier:@"toYouXiangXiuGai" sender:nil];        
    }else if (indexPath.row==2){
        [self.fourthViewController performSegueWithIdentifier:@"toGuanYuWoMen" sender:nil];
    }else if (indexPath.row==3){
        [self.fourthViewController performSegueWithIdentifier:@"toFuWuTiaoKuan" sender:nil];
    }else if (indexPath.row==4){
        [self.fourthViewController performSegueWithIdentifier:@"toYinSiDuiCe" sender:nil];
    }
}

//退出
- (IBAction)logOut:(UIButton *)sender {
    UIAlertController *vc = [UIAlertController alertControllerWithTitle:@"提示" message:@"是否退出登录？" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        NSString *urlString = [NSString stringWithFormat:@"%@/user/logout.do",JSXF_HOST];
        
        
        [ZCWebServiceHelper requestWithMethod:POST andUrlStr:urlString andParameters:nil andFinished:^(id response, NSURLSessionDataTask *dataTask) {
        }];
        
        [[ZCTool sharedInstance] logout];
        
        self.view.window.rootViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateInitialViewController];
    }];
    [vc addAction:cancleAction];
    [vc addAction:sureAction];
    [self presentViewController:vc animated:YES completion:nil];
}

@end
